Skip to content

refactor: code quality improvements#15

Merged
Detair merged 1 commit into
masterfrom
refactor/code-quality-improvements
Feb 20, 2026
Merged

refactor: code quality improvements#15
Detair merged 1 commit into
masterfrom
refactor/code-quality-improvements

Conversation

@Detair

@Detair Detair commented Feb 20, 2026

Copy link
Copy Markdown
Owner

Summary

Four code quality improvements for the v1.0 roadmap:

1. Graceful Error Handling in Audio Callback

  • Replaced assert_eq! in process_frame() with a guard clause that outputs silence on channel mismatch
  • Prevents DAW crashes when VST3/CLAP/LV2 hosts pass unexpected channel counts

2. Core Unit Tests (21 new tests)

  • NoiseFloorTracker (5 tests): initial floor, convergence, near-zero rejection, downward tracking, ring buffer wrap
  • ThreeBandEq (3 tests): flat EQ identity, construction, gain updates
  • LookaheadLimiter (4 tests): quiet boost, loud attenuation, no clipping, empty frames
  • VoidProcessor (6 tests): construction, silence to silence, bypass, gate closing, channel mismatch, process_updates
  • FrameAdapter (3 tests): roundtrip, mono duplication, partial frame buffering

3. Ring Buffer Adapter Extraction

  • New FrameAdapter struct in voidmic_core encapsulates the interleave, ring buffer, process, deinterleave pattern
  • Refactored both plugin/lib.rs and lv2/lib.rs to use it (around 80 lines of duplicated code removed)
  • Removed direct ringbuf dependency from plugin and LV2 crates

4. GUI Module Split

  • Split gui.rs (1,424 lines) into 8 focused modules under gui/:
    • mod.rs — module declarations
    • app.rs — VoidMicApp struct, constructor, eframe::App impl
    • engine.rs — start/stop/toggle engine
    • tray.rs — tray icon constants and loading
    • devices.rs — device selectors, get_devices, virtual cable installer
    • controls.rs — presets, threshold/suppression sliders
    • advanced.rs — EQ, VAD, AGC, bypass, spectrum, jitter
    • wizard.rs — first-run wizard (5 steps)

Also fixes

  • Pre-existing clippy warnings (too_many_arguments, collapsible_else_if)

Verification

  • cargo build --workspace — clean
  • cargo clippy --workspace -- -D warnings — 0 warnings
  • cargo test --workspace — 37 tests pass (16 app + 21 core)

Stats

19 files changed, 1978 insertions, 1559 deletions

- Replace assert_eq! in audio callback with graceful error handling
  to prevent DAW crashes on channel mismatch (outputs silence instead)

- Add 21 unit tests to voidmic_core (previously 0):
  NoiseFloorTracker (5), ThreeBandEq (3), LookaheadLimiter (4),
  VoidProcessor (6), FrameAdapter (3)

- Extract FrameAdapter to voidmic_core to deduplicate ring buffer
  interleave/process/deinterleave pattern shared by plugin and LV2

- Split gui.rs (1424 lines) into 8 focused modules:
  app.rs, engine.rs, tray.rs, devices.rs, controls.rs,
  advanced.rs, wizard.rs, mod.rs

- Fix pre-existing clippy warnings (too_many_arguments, collapsible_else_if)
@Detair Detair merged commit eb03345 into master Feb 20, 2026
1 of 3 checks passed
@Detair Detair deleted the refactor/code-quality-improvements branch February 20, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant